const thenable = {
  then: (resolve, reject) => {
    if (Math.random() < 0.5) {
      resolve(1);
    } else {
      reject(-1);
    }
  },
};

const p = Promise.resolve(thenable);

p.then((res) => {
  console.log(res);
}, (err) => {
  console.log(err);
});